package org.example.mapper;

import org.example.domain.User;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-12-14 18:44
 */
public class DateMapper {//通过输入的用户名查询数据库，获取用户名和密码

    /***
     * 将用户名和密码放到token中
     */
    private static Map<String, User> userData = new HashMap<String, User>();
    static{
        //初始化数据
        User u1 = new User("lan55xw","666");
        User u2 = new User("yl","888");
        //通过用户名获取对象
        userData.put(u1.getUsername(),u1);
        userData.put(u2.getUsername(),u2);
    }

    //提供静态方法，模拟数据库返回数据
    public static User getUserByName(String username){
        return userData.get(username);
    }


    public static void main(String[] args) {
        User user = getUserByName("lanxw");
        System.out.println(user);
    }
}
